package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @DubboReference  //springboot最新版的bubbo远程注入
    private UserService userService;

    /*添加账号*/
    @PostMapping("/save")
    public Integer save(@RequestBody User user){
        return userService.save(user);
    }

    /*删除账号*/
    @DeleteMapping("/delete/{id}")
    public Integer delete(@PathVariable Integer id){
        return userService.delete(id);
    }

    /*查询账号*/
    @GetMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    /*修改账号*/
    @PutMapping("/update")
    public Integer update(@RequestBody User user){
        return userService.update(user);
    }
}
